package com.cctv.custom.hibernate.integrated.wrapper;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.Criterion;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public class StudentServiceImpl implements StudentService {

	private CommonDao dao;

	@Override
	public void saveOrUpdate(Student student) {
		dao.saveOrUpdate(student);
	}

	@Override
	public boolean delete(Student student) {
		return dao.delete(student);
	}

	@Override
	public boolean delete(Long id) {
		return dao.delete(Student.class, id);
	}

	@Override
	public Student findById(Long id) {
		return dao.find(Student.class, id);
	}

	@Override
	public List<Student> listAll() {
		List<Criterion> criterions = new ArrayList<Criterion>();
		return dao.list(Student.class, criterions);
	}

	public void setDao(CommonDao dao) {
		this.dao = dao;
	}

}
